import java.util.Scanner;
public class homework4_3 {
    public static void main (String[] arga)
    {
        String goodsName ="";
        double price =0.0;
        int goodsNo =0;//商品编号
        int amount = 0;//购买数量
        double discount =0.85;//折扣比例
        double total =0.0;
        double payment =0.0;
        String goodsList = "";
        Scanner input = new Scanner (System.in);
        String answer;
        do{
            System. out.println("* * **** * ** * * * * * ******");
            System. out. println("请选择购买的商品编号:");

            System. out.println("1.T恤2.运动裤3.运动鞋");
            System. out. println("* * * * * ** *** + * .. ......	..");

            System.out.println("请输入商品编号:");
            goodsNo = input.nextInt();
            switch(goodsNo) {
                case 1:
                    goodsName = "T恤";
                    price = 260;
                    break;
                case 2:
                    goodsName = "运动裤";
                    price = 350;
                    break;
                case 3:
                    goodsName = "运动鞋";
                    price = 568;
                    break;
            }
            System.out.print("请输入购买数量:");
            amount = input.nextInt() ;
            System. out. println (goodsName+ "￥" + price +" \t 数量"+ amount +" \t 合计 ￥" + price* amount);
            total += price* amount;//连接购物清单
            goodsList = goodsList + "\n" + goodsName + "\t \t" +"￥" + price
                    +"\t \t" + amount + " \t \t" +"￥" + (price* amount)+"\t";
            System. out.print("是否继续(y/n)");
            answer =input.next();
        } while("y". equals (answer));
        System.out.println("\n");
        System.out.println("* **************消费清单*********** ** .**");
        System. out.println("购买物品\t\t"+"单价 t \t"+"个数 \t\t"+"金额\t");
        System. out. print (goodsList);
        System. out. println ("\n 折扣:"+ discount);
        System.out. println ("应付金额:"+total* discount);
        System.out.print("实付金额:");
        payment = input.nextDouble() ;
        while (payment - total* discount <0) {
            System.out.print("您输入的金额小于应付金额,请重新输入:");
            payment = input.nextDouble();
        }
        System.out. println("找钱:"+ (payment - total* discount));
        int score = (int) (total* discount)/100* 3;
        System. out.println("本次购物所获的积分是:"+ score);


    }

}
